﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Publish.aspx.cs" Inherits="FisheryPlatform.Web.Admin.Product.Publish" %>

<%@ Register TagName="Style" TagPrefix="Menu" Src="~/Modules/Menu/StyleMenu.ascx" %>
<%@ Register TagName="ShareCode" TagPrefix="pl" Src="~/Modules/Layer/PopupLayer.ascx" %>
<%@ Register TagName="Left" TagPrefix="Menu" Src="~/Modules/Menu/LeftMenu.ascx" %>
<%@ Register TagName="Header" TagPrefix="Menu" Src="~/Modules/Menu/HeaderMenu.ascx" %>
<%@ Register TagName="Footer" TagPrefix="Menu" Src="~/Modules/Menu/FooterMenu.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <Menu:Style runat="server" ID="menuStyle" Title="Hi"></Menu:Style>
    <script type="text/javascript" src="<%=FisheryPlatform.SiteConfig.SiteConfigManager.WebSite.JS%>/Pub/20110725/calendar.js"></script>
    <script type="text/javascript" src="<%=FisheryPlatform.SiteConfig.SiteConfigManager.WebSite.JS%>/Pub/20110725/PagePromptBox.js"></script>
    <script type="text/javascript" src="<%=FisheryPlatform.SiteConfig.SiteConfigManager.WebSite.JS%>/Pub/20110725/PopupLayer.js"></script>
</head>
<body>
    <div class="wrapper">
        <Menu:Header runat="server" ID="menuHeader" />
        <div class="content">
            <Menu:Left runat="server" ID="menu_Left" />
            <div class="right">
                <div class="top">
                    信息管理>>信息发布</div>
                <div class="bottom">
                    <form id="form1" runat="server">
                    <div class="edit">
                        <dl>
                            <dt><span class="validate_red">*</span> 标题：</dt><dd><input type="text" id="txt_Title"
                                runat="server" size="30" maxlength="25" class="txt_border txt_input1" /></dd>
                            <dt><span class="validate_red">*</span>类别：</dt>
                            <dd>
                                <pl:ShareCode runat="server" ID="pl_Cate" DataType="Cate" BoxSize="25" />
                            </dd>
                            <dt><span class="validate_red">*</span> 地点：</dt>
                            <dd>
                                <pl:ShareCode runat="server" ID="pl_Area" DataType="Area" BoxSize="25" />
                            </dd>
                            <dt><span class="validate_red">*</span> 供需：</dt><dd>
                                <input type="radio" value="1" name="rad_Type" onclick="jDoc('txt_Type').value=1"
                                    checked="checked" id="txt_Type1" />
                                <label for="txt_Type1">
                                    出售</label>
                                <input type="radio" value="2" name="rad_Type" onclick="jDoc('txt_Type').value=2"
                                    id="txt_Type2" />
                                <label for="txt_Type2">
                                    求购</label>
                                <input type="hidden" runat="server" id="txt_Type" value="1" /></dd>
                            <dt><span class="validate_red">*</span> 价格：</dt><dd><input type="text" id="txt_MinPrice"
                                runat="server" size="5" class="txt_border txt_input1" />-<input type="text" id="txt_MaxPrice"
                                    runat="server" size="5" class="txt_border txt_input1" />元/斤</dd>
                            <dt><span class="validate_red">*</span>描述：</dt><dd>
                                <textarea id="txt_Desc" runat="server" cols="40" rows="10" class="txt_border txt_area"></textarea></dd>
                            <dt><span class="validate_red">*</span>联系人：</dt><dd>
                                <input type="text" id="txt_Contract" runat="server" maxlength="10" class="txt_border txt_input1" /></dd>
                            <dt><span class="validate_red">*</span>手机：</dt><dd><input type="text" id="txt_Mobile"
                                runat="server" class="txt_border txt_input1" /></dd>
                            <dt>电话：</dt><dd><input type="text" id="txt_Phone" runat="server" class="txt_border txt_input1" /></dd>
                            <dt>
                                <input type="checkbox" runat="server" id="chk_ShowCustomerInfo" /></dt><dd>
                                    <label for="chk_ShowCustomerInfo">
                                        显示客户联系信息（默认显示本站联系信息）</label></dd>
                            <dt>&nbsp;</dt><dd>
                                <input type="button" value="发布" id="btn_Publish" /></dd>
                        </dl>
                    </div>
                    </form>
                </div>
            </div>
        </div>
        </form>
    </div>
</body>
</html>
<% if (result > 0)
   { %>
<script type="text/javascript">
    if(<%=result %>==1){
        alert("发布成功");
        window.location="Index.aspx";
    }else{
        alert("发布失败");
    }
</script>
<%} %>
<script type="text/javascript">
    (function () {
        if (jDoc("txt_Type").value == 1) {
            jDoc("txt_Type1").click();
        } else {
            jDoc("txt_Type2").click();
        }
        function validatePrice(o) {
            if (o.value.trim() == "" || isNaN(o.value) || parseFloat(o.value, 10) <= 0) {
                alert("价格只能填写大于0的数字");
                o.focus();
                return false;
            }
            return true;
        }
        //ElementValidator.className = { error: "error1", def: "tips", focus: "tips", correct: "correct" };
        var formValidator = new ElementValidator();
        formValidator.addText({ id: "txt_Title", focus: "标题由2-25个字符组成，禁止填写电话和特殊字符", defTips: "标题必填", len: { text: /^.{2,25}$/, errorMsg: "标题不足2个字符" }, tips: { correctMsg: "OK"} });
        formValidator.addText({ id: "txt_CateId", focus: "请选择类别", defTips: "类别必填", len: { text: /^.{1,80}$/, errorMsg: "类别必选" }, tips: { correctMsg: "OK"} });
        formValidator.addText({ id: "txt_AreaId", focus: "请选择地点", defTips: "地点必填", len: { text: /^.{1,80}$/, errorMsg: "地点必选" }, tips: { correctMsg: "OK"} });
        formValidator.addText({ id: "txt_Desc", focus: "描述由10-600个字符组成，禁止填写电话、QQ等联系方式", defTips: "描述必填", len: { text: /^.{10,600}$/, errorMsg: "描述不足10个字符" }, tips: { correctMsg: "OK"} });
        formValidator.addText({ id: "txt_Contract", focus: "请输入联系人", defTips: "联系人必填", len: { text: /^.{2,10}$/, errorMsg: "联系人由2-10个字符组成" }, tips: { correctMsg: "OK"} });
        formValidator.addText({ id: "txt_Mobile", focus: "请输入手机", defTips: "手机必填", len: { text: RegValidator.RegTextEnum.mobile, errorMsg: "手机填写错误" }, tips: { correctMsg: "OK"} });
        $(jDoc("btn_Publish")).bind("click", function () {
            var minPrice = jDoc("txt_MinPrice");
            var maxPrice = jDoc("txt_MaxPrice");
            if (validatePrice(minPrice) && validatePrice(maxPrice) && formValidator.validate()) {
                if (parseFloat(maxPrice.value) < parseFloat(minPrice.value)) {
                    alert("最高价不能小于最低价");
                    maxPrice.focus();
                    return;
                }
                jDoc("form1").submit();
            }
        });
    })()
  
</script>
